package com.groupfour.attendancemanagementsystem.controller;


import com.groupfour.attendancemanagementsystem.entity.DTO.AttendanceRecordDTO;
import com.groupfour.attendancemanagementsystem.entity.VO.*;
import com.groupfour.attendancemanagementsystem.service.AttendanceRecordService;
import com.groupfour.attendancemanagementsystem.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/attendanceManagement")
public class AttendanceManagementController {

    private AttendanceRecordService attendanceRecordService;

    @Autowired
    public AttendanceManagementController(AttendanceRecordService attendanceRecordService) {
        this.attendanceRecordService = attendanceRecordService;
    }

    /**
     * @author 牟与洋
     * @param attendanceCodeDTO
     * @return
     * @describe 查询考勤记录
     */
    @PostMapping("/selectAttendanceRecord")
    public Result selectAttendanceRecord(@RequestBody AttendanceRecordDTO attendanceCodeDTO){
        List<AttendanceRecordVO> attendanceRecordList = this.attendanceRecordService.selectAttendanceRecord(attendanceCodeDTO);
        if (attendanceRecordList != null) {
            return Result.ok(attendanceRecordList);
        }
        return Result.fail().message("暂无数据");
    }

    /**
     * @author 牟与洋
     * @describe 查询所有院系
     */
    @PostMapping("/selectDepartmentName")
    public Result selectDepartmentName() {
        List<RDepartmentVO> departmentList = attendanceRecordService.selectDepartmentName();
        if (departmentList != null) {
            return Result.ok(departmentList);
        }
        return Result.fail().message("暂无数据");
    }

    /**
     * @author 牟与洋
     * @describe 查询专业名称 (考虑与院系联动)
     */
    @PostMapping("/selectMajorName")
    public Result selectMajorName() {
        List<RMajorVO> majorList = this.attendanceRecordService.selectMajorName();
        if (majorList != null) {
            return Result.ok(majorList);
        }
        return Result.fail().message("暂无数据");
    }

    /**
     * @author 牟与洋
     * @describe 查询班级名称
     */
    @PostMapping("/selectClassesName/{gradeName}")
    public Result selectClassesName(@PathVariable String gradeName) {
        List<String> classesNameList = attendanceRecordService.selectClassesName(gradeName);
        if (classesNameList != null) {
            return Result.ok(classesNameList);
        }
        return Result.fail().message("暂无数据");
    }

    /**
     * @author 牟与洋
     * @describe 查询小组名称
     */
    @PostMapping("/selectGroupName")
    public Result selectGroupName() {
        List<AttendanceRecordVO> groupName = this.attendanceRecordService.selectGroupName();
        if (groupName != null) {
            return Result.ok(groupName);
        }
        return Result.fail().message("暂无数据");
    }

    /**
     * @describe 查询项目（课程）名称
     */
    @PostMapping("/selectCourseName")
    public Result selectCourseName() {
        List<CourseVO> courseName = this.attendanceRecordService.selectCourseName();
        if (courseName != null) {
            return Result.ok(courseName);
        }
        return Result.fail().message("暂无数据");
    }

    /**
     * @describe 查询老师名称（实训、责任）
     */
    @PostMapping("/selectTeacherName")
    public Result selectTeacherName() {
        List<CourseVO> teacherName = this.attendanceRecordService.selectTeacherName();
        if (teacherName != null) {
            return Result.ok(teacherName);
        }
        return Result.fail().message("暂无数据");
    }

}
